#ifndef GULLENGINE_SINGLETON_H
#define GULLENGINE_SINGLETON_H

#include<iostream>



namespace gull{
	namespace core{
        
        //!Template class for creating a single instance class
        /**
         * @author Jonathan Depiets
         * @date 2011 03 01
         * @version 0.1
         */
		
		template<typename T> 
		class Singleton
		{
            /** instance of the class*/
			static T* s_instance;
			
		public:
            /**Method to get the instance of the class inherite by Singleton
             *@return instance of type of the Singleton<T>
             */
			static T* getInstance();
            
            /**\brief Desxtructor
             * Call the destructor of the class inherite by Singleton
             */
			static void releaseInstance();
			
		private:
			
		};
		
		template<typename T> T* Singleton<T>::s_instance = NULL;
		
		template<typename T>
		T* Singleton<T>::getInstance(){
			if(s_instance == NULL)
				s_instance = new T;
			return s_instance;
		}
	
		template<typename T>
		void Singleton<T>::releaseInstance(){
			if(s_instance)
				delete s_instance;
			s_instance = NULL;
		}
	}
}

#endif